home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 29 / CDT29.iso / e-Mail / WorldClient Pro 2.2.3 / wcsetup.exe / GLOBALS.JS < prev    next >
Encoding:
JavaScript  |  2000-09-14  |  4.8 KB  |  165 lines

  1.  
  2. // convert all characters to lowercase to simplify testing 
  3. var agt=navigator.userAgent.toLowerCase(); 
  4.  
  5. // *** BROWSER VERSION *** 
  6. // Note: On IE5, these return 4, so use is_ie5up to detect IE5. 
  7. var is_major = parseInt(navigator.appVersion); 
  8. var is_minor = parseFloat(navigator.appVersion); 
  9.  
  10. // Note: Opera and WebTV spoof Navigator.  We do strict client detection. 
  11. // If you want to allow spoofing, take out the tests for opera and webtv. 
  12. var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
  13.             && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
  14.             && (agt.indexOf('webtv')==-1)); 
  15. var is_nav2 = (is_nav && (is_major == 2)); 
  16. var is_nav3 = (is_nav && (is_major == 3)); 
  17. var is_nav4 = (is_nav && (is_major == 4)); 
  18. var is_nav4up = (is_nav && (is_major >= 4)); 
  19. var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) || 
  20.                       (agt.indexOf("; nav") != -1)) ); 
  21. var is_nav5 = (is_nav && (is_major == 5)); 
  22. var is_nav5up = (is_nav && (is_major >= 5)); 
  23.  
  24. var is_ie   = (agt.indexOf("msie") != -1); 
  25. var is_ie3  = (is_ie && (is_major < 4)); 
  26. var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
  27. var is_ie4up  = (is_ie  && (is_major >= 4)); 
  28. var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
  29. var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 
  30.  
  31. // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser 
  32. // or if this is the first browser window opened.  Thus the 
  33. // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable. 
  34. var is_aol   = (agt.indexOf("aol") != -1); 
  35. var is_aol3  = (is_aol && is_ie3); 
  36. var is_aol4  = (is_aol && is_ie4); 
  37.  
  38. var is_opera = (agt.indexOf("opera") != -1); 
  39. var is_webtv = (agt.indexOf("webtv") != -1); 
  40.  
  41. // *** JAVASCRIPT VERSION CHECK *** 
  42. var is_js; 
  43. if (is_nav2 || is_ie3) is_js = 1.0 
  44. else if (is_nav3 || is_opera) is_js = 1.1 
  45. else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2 
  46. else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3 
  47. else if (is_nav5) is_js = 1.4 
  48. // NOTE: In the future, update this code when newer versions of JS 
  49. // are released. For now, we try to provide some upward compatibility 
  50. // so that future versions of Nav and IE will show they are at 
  51. // *least* JS 1.x capable. Always check for JS version compatibility 
  52. // with > or >=. 
  53. else if (is_nav && (is_major > 5)) is_js = 1.4 
  54. else if (is_ie && (is_major > 5)) is_js = 1.3 
  55. // HACK: no idea for other browsers; always check for JS version with > or >= 
  56. else is_js = 0.0; 
  57.  
  58.  
  59. function Mesg(Msg)
  60. {
  61.     if (Msg.length > 0)
  62.         alert(Msg);
  63. }
  64.  
  65. function Post(field, value)
  66. {
  67.     document.forms[0].action += '&' + field + '=';
  68.     if (value != null)
  69.         document.forms[0].action += value;
  70.     else
  71.         document.forms[0].action += 'Yes';
  72.  
  73.     if (typeof(Validate) == 'undefined' || Validate())
  74.         document.forms[0].submit();
  75. }
  76.  
  77. function Get(field, value)
  78. {
  79.     var url = document.forms[0].action += '&' + field + '=';
  80.     if (value != null)
  81.         url += value;
  82.     else
  83.         url += 'Yes';
  84.     document.location = url;
  85. }
  86.  
  87. function SetOption(name, value)
  88. {
  89.     for (var i=0; i<document.forms[0].length; i++)
  90.     {
  91.         if (document.forms[0].elements[i].name == name)
  92.             var element = document.forms[0].elements[i];
  93.     }
  94.     if (element == null)
  95.         return;
  96.  
  97.     if (element.type == 'checkbox')
  98.     {
  99.         if (element.value == value)
  100.             element.checked = true;
  101.     }
  102.     else if (element.type == 'radio')
  103.     {
  104.         for (var i=0; i<document.forms[0].length; i++)
  105.         {
  106.             if (document.forms[0].elements[i].name == name &&
  107.                 document.forms[0].elements[i].value == value)
  108.                 document.forms[0].elements[i].checked = true;
  109.         }
  110.     }
  111.     else if (element.type == 'select-one')
  112.     {
  113.         for (var i=0; i<element.length; i++)
  114.         {
  115.             if (element.options[i].value == value)
  116.                 element.selectedIndex = i;
  117.         }
  118.     }
  119.     else if (element.type == 'text')
  120.     {
  121.         element.value = value;
  122.     }
  123. }
  124.  
  125. /* List View Functions */
  126. function Sort(SortKey)
  127. {
  128.     var F=document.forms[0];
  129.     if (F.Sort.value.indexOf(SortKey) == -1)
  130.         F.Sort.value = SortKey;
  131.     else
  132.     {
  133.         if (F.Sort.value.indexOf('Rev') == -1)
  134.             F.Sort.value = 'Rev' + SortKey;
  135.         else
  136.             F.Sort.value = SortKey;
  137.     }
  138.     F.submit(); 
  139. }
  140.  
  141. function SelectAll() {
  142.     for (var i=0;i<document.forms[0].elements.length;i++) {
  143.         var e=document.forms[0].elements[i];
  144.         e.checked=!e.checked;
  145.     }
  146. }
  147.  
  148. function ChangeFolder() {
  149.     var F=document.forms[0];
  150.     F.DestFolder.selectedIndex=F.BottomFolder.selectedIndex;
  151. }
  152.  
  153. function ChangeBottomFolder() {
  154.     var F=document.forms[0];
  155.     F.BottomFolder.selectedIndex=F.DestFolder.selectedIndex;
  156. }
  157.  
  158. /* Message View Functions */
  159. function Print(url) {
  160.     window.open(url,'Print','height=400,width=600,scrollbars=yes,status=yes,resizable=1,toolbar=yes,menubar=yes');
  161. }
  162.  
  163. function Source(url) {
  164.     window.open(url,'Source','height=400,width=600,scrollbars=yes,status=yes,resizable=1');
  165. }